library(corpcor)
library(GPArotation)
library(psych)
library(REdaS)
## Loading required package: grid
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
##
## Attaching package: 'Hmisc'
## The following object is masked from 'package:psych':
##
## describe
## The following objects are masked from 'package:base':
##
## format.pval, units
library(corrplot)
## corrplot 0.84 loaded
library(ggcorrplot)
library(factoextra)
## Welcome! Related Books: `Practical Guide To Cluster Analysis in R` at https://goo.gl/13EFCZ
library(nFactors)
## Loading required package: MASS
## Loading required package: boot
##
## Attaching package: 'boot'
## The following object is masked from 'package:survival':
##
## aml
## The following object is masked from 'package:lattice':
##
## melanoma
## The following object is masked from 'package:psych':
##
## logit
##
## Attaching package: 'nFactors'
## The following object is masked from 'package:lattice':
##
## parallel
#We are using a .dat file from Field, Miles and Field Discovering Statistics with R, a survey on fear of statistics - raq.dat
#load data
raqData<-read.delim("raq.dat", header = TRUE)
#create a correlation matrix (these are just some methods)
raqMatrix<-cor(raqData)
round(raqMatrix, 2)
## Q01 Q02 Q03 Q04 Q05 Q06 Q07 Q08 Q09 Q10 Q11
## Q01 1.00 -0.10 -0.34 0.44 0.40 0.22 0.31 0.33 -0.09 0.21 0.36
## Q02 -0.10 1.00 0.32 -0.11 -0.12 -0.07 -0.16 -0.05 0.31 -0.08 -0.14
## Q03 -0.34 0.32 1.00 -0.38 -0.31 -0.23 -0.38 -0.26 0.30 -0.19 -0.35
## Q04 0.44 -0.11 -0.38 1.00 0.40 0.28 0.41 0.35 -0.12 0.22 0.37
## Q05 0.40 -0.12 -0.31 0.40 1.00 0.26 0.34 0.27 -0.10 0.26 0.30
## Q06 0.22 -0.07 -0.23 0.28 0.26 1.00 0.51 0.22 -0.11 0.32 0.33
## Q07 0.31 -0.16 -0.38 0.41 0.34 0.51 1.00 0.30 -0.13 0.28 0.34
## Q08 0.33 -0.05 -0.26 0.35 0.27 0.22 0.30 1.00 0.02 0.16 0.63
## Q09 -0.09 0.31 0.30 -0.12 -0.10 -0.11 -0.13 0.02 1.00 -0.13 -0.12
## Q10 0.21 -0.08 -0.19 0.22 0.26 0.32 0.28 0.16 -0.13 1.00 0.27
## Q11 0.36 -0.14 -0.35 0.37 0.30 0.33 0.34 0.63 -0.12 0.27 1.00
## Q12 0.35 -0.19 -0.41 0.44 0.35 0.31 0.42 0.25 -0.17 0.25 0.34
## Q13 0.35 -0.14 -0.32 0.34 0.30 0.47 0.44 0.31 -0.17 0.30 0.42
## Q14 0.34 -0.16 -0.37 0.35 0.32 0.40 0.44 0.28 -0.12 0.25 0.33
## Q15 0.25 -0.16 -0.31 0.33 0.26 0.36 0.39 0.30 -0.19 0.30 0.36
## Q16 0.50 -0.17 -0.42 0.42 0.39 0.24 0.39 0.32 -0.19 0.29 0.37
## Q17 0.37 -0.09 -0.33 0.38 0.31 0.28 0.39 0.59 -0.04 0.22 0.59
## Q18 0.35 -0.16 -0.38 0.38 0.32 0.51 0.50 0.28 -0.15 0.29 0.37
## Q19 -0.19 0.20 0.34 -0.19 -0.17 -0.17 -0.27 -0.16 0.25 -0.13 -0.20
## Q20 0.21 -0.20 -0.32 0.24 0.20 0.10 0.22 0.18 -0.16 0.08 0.26
## Q21 0.33 -0.20 -0.42 0.41 0.33 0.27 0.48 0.30 -0.14 0.19 0.35
## Q22 -0.10 0.23 0.20 -0.10 -0.13 -0.17 -0.17 -0.08 0.26 -0.13 -0.16
## Q23 0.00 0.10 0.15 -0.03 -0.04 -0.07 -0.07 -0.05 0.17 -0.06 -0.09
## Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22
## Q01 0.35 0.35 0.34 0.25 0.50 0.37 0.35 -0.19 0.21 0.33 -0.10
## Q02 -0.19 -0.14 -0.16 -0.16 -0.17 -0.09 -0.16 0.20 -0.20 -0.20 0.23
## Q03 -0.41 -0.32 -0.37 -0.31 -0.42 -0.33 -0.38 0.34 -0.32 -0.42 0.20
## Q04 0.44 0.34 0.35 0.33 0.42 0.38 0.38 -0.19 0.24 0.41 -0.10
## Q05 0.35 0.30 0.32 0.26 0.39 0.31 0.32 -0.17 0.20 0.33 -0.13
## Q06 0.31 0.47 0.40 0.36 0.24 0.28 0.51 -0.17 0.10 0.27 -0.17
## Q07 0.42 0.44 0.44 0.39 0.39 0.39 0.50 -0.27 0.22 0.48 -0.17
## Q08 0.25 0.31 0.28 0.30 0.32 0.59 0.28 -0.16 0.18 0.30 -0.08
## Q09 -0.17 -0.17 -0.12 -0.19 -0.19 -0.04 -0.15 0.25 -0.16 -0.14 0.26
## Q10 0.25 0.30 0.25 0.30 0.29 0.22 0.29 -0.13 0.08 0.19 -0.13
## Q11 0.34 0.42 0.33 0.36 0.37 0.59 0.37 -0.20 0.26 0.35 -0.16
## Q12 1.00 0.49 0.43 0.33 0.41 0.33 0.49 -0.27 0.30 0.44 -0.17
## Q13 0.49 1.00 0.45 0.34 0.36 0.41 0.53 -0.23 0.20 0.37 -0.20
## Q14 0.43 0.45 1.00 0.38 0.42 0.35 0.50 -0.25 0.23 0.40 -0.17
## Q15 0.33 0.34 0.38 1.00 0.45 0.37 0.34 -0.21 0.21 0.30 -0.17
## Q16 0.41 0.36 0.42 0.45 1.00 0.41 0.42 -0.27 0.27 0.42 -0.16
## Q17 0.33 0.41 0.35 0.37 0.41 1.00 0.38 -0.16 0.21 0.36 -0.13
## Q18 0.49 0.53 0.50 0.34 0.42 0.38 1.00 -0.26 0.24 0.43 -0.16
## Q19 -0.27 -0.23 -0.25 -0.21 -0.27 -0.16 -0.26 1.00 -0.25 -0.27 0.23
## Q20 0.30 0.20 0.23 0.21 0.27 0.21 0.24 -0.25 1.00 0.47 -0.10
## Q21 0.44 0.37 0.40 0.30 0.42 0.36 0.43 -0.27 0.47 1.00 -0.13
## Q22 -0.17 -0.20 -0.17 -0.17 -0.16 -0.13 -0.16 0.23 -0.10 -0.13 1.00
## Q23 -0.05 -0.05 -0.05 -0.06 -0.08 -0.09 -0.08 0.12 -0.03 -0.07 0.23
## Q23
## Q01 0.00
## Q02 0.10
## Q03 0.15
## Q04 -0.03
## Q05 -0.04
## Q06 -0.07
## Q07 -0.07
## Q08 -0.05
## Q09 0.17
## Q10 -0.06
## Q11 -0.09
## Q12 -0.05
## Q13 -0.05
## Q14 -0.05
## Q15 -0.06
## Q16 -0.08
## Q17 -0.09
## Q18 -0.08
## Q19 0.12
## Q20 -0.03
## Q21 -0.07
## Q22 0.23
## Q23 1.00
Hmisc::rcorr(as.matrix(raqData))
## Q01 Q02 Q03 Q04 Q05 Q06 Q07 Q08 Q09 Q10 Q11
## Q01 1.00 -0.10 -0.34 0.44 0.40 0.22 0.31 0.33 -0.09 0.21 0.36
## Q02 -0.10 1.00 0.32 -0.11 -0.12 -0.07 -0.16 -0.05 0.31 -0.08 -0.14
## Q03 -0.34 0.32 1.00 -0.38 -0.31 -0.23 -0.38 -0.26 0.30 -0.19 -0.35
## Q04 0.44 -0.11 -0.38 1.00 0.40 0.28 0.41 0.35 -0.12 0.22 0.37
## Q05 0.40 -0.12 -0.31 0.40 1.00 0.26 0.34 0.27 -0.10 0.26 0.30
## Q06 0.22 -0.07 -0.23 0.28 0.26 1.00 0.51 0.22 -0.11 0.32 0.33
## Q07 0.31 -0.16 -0.38 0.41 0.34 0.51 1.00 0.30 -0.13 0.28 0.34
## Q08 0.33 -0.05 -0.26 0.35 0.27 0.22 0.30 1.00 0.02 0.16 0.63
## Q09 -0.09 0.31 0.30 -0.12 -0.10 -0.11 -0.13 0.02 1.00 -0.13 -0.12
## Q10 0.21 -0.08 -0.19 0.22 0.26 0.32 0.28 0.16 -0.13 1.00 0.27
## Q11 0.36 -0.14 -0.35 0.37 0.30 0.33 0.34 0.63 -0.12 0.27 1.00
## Q12 0.35 -0.19 -0.41 0.44 0.35 0.31 0.42 0.25 -0.17 0.25 0.34
## Q13 0.35 -0.14 -0.32 0.34 0.30 0.47 0.44 0.31 -0.17 0.30 0.42
## Q14 0.34 -0.16 -0.37 0.35 0.32 0.40 0.44 0.28 -0.12 0.25 0.33
## Q15 0.25 -0.16 -0.31 0.33 0.26 0.36 0.39 0.30 -0.19 0.30 0.36
## Q16 0.50 -0.17 -0.42 0.42 0.39 0.24 0.39 0.32 -0.19 0.29 0.37
## Q17 0.37 -0.09 -0.33 0.38 0.31 0.28 0.39 0.59 -0.04 0.22 0.59
## Q18 0.35 -0.16 -0.38 0.38 0.32 0.51 0.50 0.28 -0.15 0.29 0.37
## Q19 -0.19 0.20 0.34 -0.19 -0.17 -0.17 -0.27 -0.16 0.25 -0.13 -0.20
## Q20 0.21 -0.20 -0.32 0.24 0.20 0.10 0.22 0.18 -0.16 0.08 0.26
## Q21 0.33 -0.20 -0.42 0.41 0.33 0.27 0.48 0.30 -0.14 0.19 0.35
## Q22 -0.10 0.23 0.20 -0.10 -0.13 -0.17 -0.17 -0.08 0.26 -0.13 -0.16
## Q23 0.00 0.10 0.15 -0.03 -0.04 -0.07 -0.07 -0.05 0.17 -0.06 -0.09
## Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22
## Q01 0.35 0.35 0.34 0.25 0.50 0.37 0.35 -0.19 0.21 0.33 -0.10
## Q02 -0.19 -0.14 -0.16 -0.16 -0.17 -0.09 -0.16 0.20 -0.20 -0.20 0.23
## Q03 -0.41 -0.32 -0.37 -0.31 -0.42 -0.33 -0.38 0.34 -0.32 -0.42 0.20
## Q04 0.44 0.34 0.35 0.33 0.42 0.38 0.38 -0.19 0.24 0.41 -0.10
## Q05 0.35 0.30 0.32 0.26 0.39 0.31 0.32 -0.17 0.20 0.33 -0.13
## Q06 0.31 0.47 0.40 0.36 0.24 0.28 0.51 -0.17 0.10 0.27 -0.17
## Q07 0.42 0.44 0.44 0.39 0.39 0.39 0.50 -0.27 0.22 0.48 -0.17
## Q08 0.25 0.31 0.28 0.30 0.32 0.59 0.28 -0.16 0.18 0.30 -0.08
## Q09 -0.17 -0.17 -0.12 -0.19 -0.19 -0.04 -0.15 0.25 -0.16 -0.14 0.26
## Q10 0.25 0.30 0.25 0.30 0.29 0.22 0.29 -0.13 0.08 0.19 -0.13
## Q11 0.34 0.42 0.33 0.36 0.37 0.59 0.37 -0.20 0.26 0.35 -0.16
## Q12 1.00 0.49 0.43 0.33 0.41 0.33 0.49 -0.27 0.30 0.44 -0.17
## Q13 0.49 1.00 0.45 0.34 0.36 0.41 0.53 -0.23 0.20 0.37 -0.20
## Q14 0.43 0.45 1.00 0.38 0.42 0.35 0.50 -0.25 0.23 0.40 -0.17
## Q15 0.33 0.34 0.38 1.00 0.45 0.37 0.34 -0.21 0.21 0.30 -0.17
## Q16 0.41 0.36 0.42 0.45 1.00 0.41 0.42 -0.27 0.27 0.42 -0.16
## Q17 0.33 0.41 0.35 0.37 0.41 1.00 0.38 -0.16 0.21 0.36 -0.13
## Q18 0.49 0.53 0.50 0.34 0.42 0.38 1.00 -0.26 0.24 0.43 -0.16
## Q19 -0.27 -0.23 -0.25 -0.21 -0.27 -0.16 -0.26 1.00 -0.25 -0.27 0.23
## Q20 0.30 0.20 0.23 0.21 0.27 0.21 0.24 -0.25 1.00 0.47 -0.10
## Q21 0.44 0.37 0.40 0.30 0.42 0.36 0.43 -0.27 0.47 1.00 -0.13
## Q22 -0.17 -0.20 -0.17 -0.17 -0.16 -0.13 -0.16 0.23 -0.10 -0.13 1.00
## Q23 -0.05 -0.05 -0.05 -0.06 -0.08 -0.09 -0.08 0.12 -0.03 -0.07 0.23
## Q23
## Q01 0.00
## Q02 0.10
## Q03 0.15
## Q04 -0.03
## Q05 -0.04
## Q06 -0.07
## Q07 -0.07
## Q08 -0.05
## Q09 0.17
## Q10 -0.06
## Q11 -0.09
## Q12 -0.05
## Q13 -0.05
## Q14 -0.05
## Q15 -0.06
## Q16 -0.08
## Q17 -0.09
## Q18 -0.08
## Q19 0.12
## Q20 -0.03
## Q21 -0.07
## Q22 0.23
## Q23 1.00
##
## n= 2571
##
##
## P
## Q01 Q02 Q03 Q04 Q05 Q06 Q07 Q08 Q09 Q10
## Q01 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q02 0.0000 0.0000 0.0000 0.0000 0.0002 0.0000 0.0119 0.0000 0.0000
## Q03 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q04 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q05 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q06 0.0000 0.0002 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q07 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q08 0.0000 0.0119 0.0000 0.0000 0.0000 0.0000 0.0000 0.4252 0.0000
## Q09 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.4252 0.0000
## Q10 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q11 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q12 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q13 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q14 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q15 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q16 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q17 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0620 0.0000
## Q18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q19 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q20 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q21 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q22 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q23 0.8204 0.0000 0.0000 0.0865 0.0347 0.0005 0.0004 0.0108 0.0000 0.0017
## Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20
## Q01 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q02 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q03 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q04 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q05 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q06 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q07 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q08 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q09 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0620 0.0000 0.0000 0.0000
## Q10 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q11 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q12 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q13 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q14 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q15 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q16 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q17 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q18 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q19 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q20 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q21 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q22 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## Q23 0.0000 0.0186 0.0072 0.0140 0.0017 0.0000 0.0000 0.0000 0.0000 0.0789
## Q21 Q22 Q23
## Q01 0.0000 0.0000 0.8204
## Q02 0.0000 0.0000 0.0000
## Q03 0.0000 0.0000 0.0000
## Q04 0.0000 0.0000 0.0865
## Q05 0.0000 0.0000 0.0347
## Q06 0.0000 0.0000 0.0005
## Q07 0.0000 0.0000 0.0004
## Q08 0.0000 0.0000 0.0108
## Q09 0.0000 0.0000 0.0000
## Q10 0.0000 0.0000 0.0017
## Q11 0.0000 0.0000 0.0000
## Q12 0.0000 0.0000 0.0186
## Q13 0.0000 0.0000 0.0072
## Q14 0.0000 0.0000 0.0140
## Q15 0.0000 0.0000 0.0017
## Q16 0.0000 0.0000 0.0000
## Q17 0.0000 0.0000 0.0000
## Q18 0.0000 0.0000 0.0000
## Q19 0.0000 0.0000 0.0000
## Q20 0.0000 0.0000 0.0789
## Q21 0.0000 0.0006
## Q22 0.0000 0.0000
## Q23 0.0006 0.0000
#Using ggcorrplot
p.mat <- ggcorrplot::cor_pmat(raqData)
ggcorrplot::ggcorrplot(raqMatrix, title = "Correlation matrix for RAQ data")
#Showing Xs for non-significant correlations
ggcorrplot::ggcorrplot(raqMatrix, title = "Correlation matrix for RAQ data", p.mat = p.mat, sig.level = .05)
#Showing lower diagonal
ggcorrplot::ggcorrplot(raqMatrix, title = "Correlation matrix for RAQ data", p.mat = p.mat, sig.level = .05, type="lower")
#Showing the co-efficients
ggcorrplot::ggcorrplot(raqMatrix, lab=TRUE, title = "Correlation matrix for RAQ data", type="lower")
###Using corrplot
#Visualisation of correlations using circles
#corrplot parameters method = c("circle", "square", "ellipse", "number", "shade",
#"color", "pie")
#type = c("full", "lower", "upper"),
corrplot::corrplot(raqMatrix, method="circle")
corrplot::corrplot(raqMatrix, method="circle", type="upper")
#Visualisation using numbers
corrplot::corrplot(raqMatrix, method="number")
#Visualisation of significance levels at 0.05
res1 <- corrplot::cor.mtest(raqMatrix, conf.level = .95)
corrplot::corrplot(raqMatrix, p.mat = res1$p, type="lower", sig.level = .05)
#Showing p-value for non-significant results
corrplot(raqMatrix, p.mat = res1$p, type="lower",insig = "p-value")
#Bartlett's test
psych::cortest.bartlett(raqData)
## R was not square, finding R from data
## $chisq
## [1] 19334.49
##
## $p.value
## [1] 0
##
## $df
## [1] 253
psych::cortest.bartlett(raqMatrix, n = 2571)
## $chisq
## [1] 19334.49
##
## $p.value
## [1] 0
##
## $df
## [1] 253
#KMO (execute one of these):
REdaS::KMOS(raqData)
##
## Kaiser-Meyer-Olkin Statistics
##
## Call: REdaS::KMOS(x = raqData)
##
## Measures of Sampling Adequacy (MSA):
## Q01 Q02 Q03 Q04 Q05 Q06 Q07
## 0.9297610 0.8747754 0.9510378 0.9553403 0.9600892 0.8913314 0.9416800
## Q08 Q09 Q10 Q11 Q12 Q13 Q14
## 0.8713055 0.8337295 0.9486858 0.9059338 0.9548324 0.9482270 0.9671722
## Q15 Q16 Q17 Q18 Q19 Q20 Q21
## 0.9404402 0.9336439 0.9306205 0.9479508 0.9407021 0.8890514 0.9293369
## Q22 Q23
## 0.8784508 0.7663994
##
## KMO-Criterion: 0.9302245
psych::KMO(raqData)
## Kaiser-Meyer-Olkin factor adequacy
## Call: psych::KMO(r = raqData)
## Overall MSA = 0.93
## MSA for each item =
## Q01 Q02 Q03 Q04 Q05 Q06 Q07 Q08 Q09 Q10 Q11 Q12 Q13 Q14 Q15
## 0.93 0.87 0.95 0.96 0.96 0.89 0.94 0.87 0.83 0.95 0.91 0.95 0.95 0.97 0.94
## Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23
## 0.93 0.93 0.95 0.94 0.89 0.93 0.88 0.77
#Determinent (execute one of these):
det(raqMatrix)
## [1] 0.0005271037
det(cor(raqData))
## [1] 0.0005271037
#pcModel<-principal(dataframe/R-matrix, nfactors = number of factors, rotate = "method of rotation", scores = TRUE)
#On raw data using principal components analysis
#For PCA we know how many factors if is possible to find
#principal will work out our loadings of each variable onto each component, the proportion each component explained and the cummulative proportion of variance explai
pc1 <- principal(raqData, nfactors = 23, rotate = "none")
pc1 <- principal(raqData, nfactors = length(raqData), rotate = "none")
pc1#output all details of the PCA
## Principal Components Analysis
## Call: principal(r = raqData, nfactors = length(raqData), rotate = "none")
## Standardized loadings (pattern matrix) based upon correlation matrix
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11
## Q01 0.59 0.18 -0.22 0.12 -0.40 -0.11 -0.22 -0.08 0.01 -0.10 0.11
## Q02 -0.30 0.55 0.15 0.01 -0.03 -0.38 0.19 -0.39 0.01 -0.12 0.30
## Q03 -0.63 0.29 0.21 -0.07 0.02 0.00 0.01 -0.05 0.20 0.10 0.15
## Q04 0.63 0.14 -0.15 0.15 -0.20 -0.12 -0.06 0.11 -0.11 -0.01 -0.03
## Q05 0.56 0.10 -0.07 0.14 -0.42 -0.17 -0.06 0.11 0.24 0.09 -0.30
## Q06 0.56 0.10 0.57 -0.05 0.17 0.01 0.00 0.05 0.00 0.00 -0.13
## Q07 0.69 0.04 0.25 0.10 0.17 -0.08 0.05 0.03 -0.08 0.13 -0.27
## Q08 0.55 0.40 -0.32 -0.42 0.15 0.10 -0.07 -0.04 0.01 -0.05 -0.09
## Q09 -0.28 0.63 -0.01 0.10 0.17 -0.27 -0.01 -0.03 0.16 0.32 -0.22
## Q10 0.44 0.03 0.36 -0.10 -0.34 0.22 0.44 -0.03 0.37 -0.22 -0.11
## Q11 0.65 0.25 -0.21 -0.40 0.13 0.18 -0.01 0.03 0.10 -0.14 0.00
## Q12 0.67 -0.05 0.05 0.25 0.04 -0.08 -0.14 0.08 0.01 -0.11 0.19
## Q13 0.67 0.08 0.28 -0.01 0.13 0.03 -0.21 0.05 0.08 -0.22 0.24
## Q14 0.66 0.02 0.20 0.14 0.08 -0.03 -0.10 -0.06 -0.14 0.16 0.08
## Q15 0.59 0.01 0.12 -0.11 -0.07 0.29 0.32 -0.12 -0.27 0.41 0.15
## Q16 0.68 0.01 -0.14 0.08 -0.32 0.00 0.12 -0.14 -0.19 0.15 0.16
## Q17 0.64 0.33 -0.21 -0.34 0.10 0.05 -0.02 0.03 -0.04 0.02 0.01
## Q18 0.70 0.03 0.30 0.13 0.15 -0.09 -0.10 0.06 -0.06 -0.12 0.05
## Q19 -0.43 0.39 0.10 -0.01 -0.15 0.07 0.05 0.68 0.02 0.16 0.29
## Q20 0.44 -0.21 -0.40 0.30 0.33 -0.01 0.34 0.03 0.33 0.02 0.21
## Q21 0.66 -0.06 -0.19 0.28 0.24 -0.15 0.18 0.10 0.12 0.08 -0.02
## Q22 -0.30 0.47 -0.12 0.38 0.07 0.12 0.31 0.12 -0.41 -0.39 -0.19
## Q23 -0.14 0.37 -0.02 0.51 0.02 0.62 -0.28 -0.22 0.18 0.08 0.00
## PC12 PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20 PC21 PC22
## Q01 -0.12 0.30 -0.25 0.18 0.12 -0.05 -0.17 0.16 -0.01 -0.21 0.05
## Q02 0.27 -0.02 0.01 -0.24 -0.05 -0.08 0.00 0.01 -0.02 -0.02 0.03
## Q03 0.03 0.10 0.13 0.40 -0.06 0.43 0.08 0.09 0.05 0.01 0.00
## Q04 0.34 -0.32 -0.17 0.12 0.31 0.19 0.05 -0.21 0.04 0.09 -0.02
## Q05 0.16 0.12 0.48 -0.07 -0.08 -0.04 0.01 -0.04 0.00 -0.02 0.02
## Q06 0.20 0.24 -0.03 0.08 0.20 -0.14 0.05 0.09 -0.07 0.04 -0.32
## Q07 0.20 0.04 -0.22 0.00 -0.23 0.03 -0.15 0.20 0.16 0.14 0.24
## Q08 0.03 -0.01 0.04 -0.04 0.03 0.10 0.07 0.12 -0.15 0.06 0.16
## Q09 -0.37 -0.17 -0.07 0.12 0.11 -0.19 -0.02 -0.08 -0.03 0.04 -0.01
## Q10 -0.21 -0.17 -0.15 -0.07 0.03 0.07 -0.01 0.00 0.04 -0.03 0.02
## Q11 0.03 0.02 0.03 -0.02 0.07 -0.05 0.07 0.07 -0.18 0.06 0.00
## Q12 -0.07 -0.45 0.17 0.09 -0.10 -0.08 0.04 0.36 0.00 -0.04 -0.10
## Q13 -0.08 0.01 0.12 0.14 -0.11 -0.06 -0.32 -0.30 -0.06 0.16 0.08
## Q14 -0.29 0.07 0.14 -0.37 0.25 0.34 -0.09 0.06 0.02 0.03 -0.01
## Q15 0.09 -0.09 0.16 0.16 0.06 -0.12 -0.10 -0.04 -0.07 -0.19 0.10
## Q16 -0.19 0.12 -0.08 0.06 -0.22 -0.03 0.22 -0.02 -0.04 0.35 -0.12
## Q17 -0.03 -0.01 -0.01 -0.05 -0.18 0.04 -0.04 -0.10 0.42 -0.15 -0.23
## Q18 -0.11 0.09 0.00 0.03 -0.01 -0.06 0.45 -0.15 0.08 -0.18 0.23
## Q19 0.04 0.06 -0.09 -0.16 -0.03 -0.06 0.01 0.05 -0.02 0.02 0.04
## Q20 0.04 0.17 0.07 0.05 0.22 -0.09 0.00 0.04 0.18 0.10 0.06
## Q21 0.04 0.03 -0.15 -0.04 -0.27 0.20 -0.03 -0.11 -0.31 -0.20 -0.13
## Q22 -0.10 0.08 0.15 0.09 0.01 0.04 -0.06 0.02 0.00 0.01 -0.01
## Q23 0.13 -0.01 -0.07 -0.12 -0.06 -0.03 0.05 -0.03 0.01 -0.01 -0.02
## PC23 h2 u2 com
## Q01 0.01 1 -1.1e-15 6.0
## Q02 0.02 1 -3.8e-15 6.1
## Q03 0.05 1 6.7e-16 4.4
## Q04 0.02 1 -1.1e-15 4.9
## Q05 0.01 1 -6.7e-16 5.2
## Q06 -0.11 1 -4.4e-16 4.4
## Q07 0.09 1 -4.4e-16 4.1
## Q08 -0.36 1 -1.3e-15 5.7
## Q09 0.03 1 -1.3e-15 5.0
## Q10 -0.04 1 2.2e-16 7.7
## Q11 0.41 1 -1.3e-15 4.1
## Q12 -0.02 1 -1.6e-15 3.8
## Q13 -0.05 1 -1.6e-15 4.2
## Q14 0.05 1 -1.1e-15 4.3
## Q15 0.00 1 -6.7e-16 5.6
## Q16 -0.01 1 -1.8e-15 4.0
## Q17 -0.01 1 -1.6e-15 4.3
## Q18 0.01 1 -1.1e-15 3.4
## Q19 -0.02 1 -8.9e-16 3.5
## Q20 -0.04 1 4.4e-16 8.7
## Q21 -0.01 1 -2.2e-16 4.6
## Q22 0.01 1 0.0e+00 7.2
## Q23 0.00 1 1.1e-16 4.2
##
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10
## SS loadings 7.29 1.74 1.32 1.23 0.99 0.90 0.81 0.78 0.75 0.72
## Proportion Var 0.32 0.08 0.06 0.05 0.04 0.04 0.04 0.03 0.03 0.03
## Cumulative Var 0.32 0.39 0.45 0.50 0.55 0.59 0.62 0.65 0.69 0.72
## Proportion Explained 0.32 0.08 0.06 0.05 0.04 0.04 0.04 0.03 0.03 0.03
## Cumulative Proportion 0.32 0.39 0.45 0.50 0.55 0.59 0.62 0.65 0.69 0.72
## PC11 PC12 PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20
## SS loadings 0.68 0.67 0.61 0.58 0.55 0.52 0.51 0.46 0.42 0.41
## Proportion Var 0.03 0.03 0.03 0.03 0.02 0.02 0.02 0.02 0.02 0.02
## Cumulative Var 0.75 0.78 0.80 0.83 0.85 0.88 0.90 0.92 0.94 0.95
## Proportion Explained 0.03 0.03 0.03 0.03 0.02 0.02 0.02 0.02 0.02 0.02
## Cumulative Proportion 0.75 0.78 0.80 0.83 0.85 0.88 0.90 0.92 0.94 0.95
## PC21 PC22 PC23
## SS loadings 0.38 0.36 0.33
## Proportion Var 0.02 0.02 0.01
## Cumulative Var 0.97 0.99 1.00
## Proportion Explained 0.02 0.02 0.01
## Cumulative Proportion 0.97 0.99 1.00
##
## Mean item complexity = 5
## Test of the hypothesis that 23 components are sufficient.
##
## The root mean square of the residuals (RMSR) is 0
## with the empirical chi square 0 with prob < NA
##
## Fit based upon off diagonal values = 1
psych::print.psych(pc1, cut = 0.3, sort = TRUE)
## Principal Components Analysis
## Call: principal(r = raqData, nfactors = length(raqData), rotate = "none")
## Standardized loadings (pattern matrix) based upon correlation matrix
## item PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11
## Q18 18 0.70
## Q07 7 0.69
## Q16 16 0.68 -0.32
## Q13 13 0.67
## Q12 12 0.67
## Q21 21 0.66
## Q14 14 0.66
## Q11 11 0.65 -0.40
## Q17 17 0.64 0.33 -0.34
## Q04 4 0.63
## Q03 3 -0.63
## Q15 15 0.59 0.32 0.41
## Q01 1 0.59 -0.40
## Q05 5 0.56 -0.42
## Q08 8 0.55 0.40 -0.32 -0.42
## Q10 10 0.44 0.36 -0.34 0.44 0.37
## Q20 20 0.44 -0.40 0.33 0.34 0.33
## Q09 9 0.63 0.32
## Q02 2 -0.30 0.55 -0.38 -0.39 0.30
## Q22 22 -0.30 0.47 0.38 0.31 -0.41 -0.39
## Q06 6 0.56 0.57
## Q23 23 0.37 0.51 0.62
## Q19 19 -0.43 0.39 0.68
## PC12 PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20 PC21 PC22
## Q18 0.45
## Q07
## Q16 0.35
## Q13 -0.32
## Q12 -0.45 0.36
## Q21 -0.31
## Q14 -0.37 0.34
## Q11
## Q17 0.42
## Q04 0.34 -0.32 0.31
## Q03 0.40 0.43
## Q15
## Q01
## Q05 0.48
## Q08
## Q10
## Q20
## Q09 -0.37
## Q02
## Q22
## Q06 -0.32
## Q23
## Q19
## PC23 h2 u2 com
## Q18 1 -1.1e-15 3.4
## Q07 1 -4.4e-16 4.1
## Q16 1 -1.8e-15 4.0
## Q13 1 -1.6e-15 4.2
## Q12 1 -1.6e-15 3.8
## Q21 1 -2.2e-16 4.6
## Q14 1 -1.1e-15 4.3
## Q11 0.41 1 -1.3e-15 4.1
## Q17 1 -1.6e-15 4.3
## Q04 1 -1.1e-15 4.9
## Q03 1 6.7e-16 4.4
## Q15 1 -6.7e-16 5.6
## Q01 1 -1.1e-15 6.0
## Q05 1 -6.7e-16 5.2
## Q08 -0.36 1 -1.3e-15 5.7
## Q10 1 2.2e-16 7.7
## Q20 1 4.4e-16 8.7
## Q09 1 -1.3e-15 5.0
## Q02 1 -3.8e-15 6.1
## Q22 1 0.0e+00 7.2
## Q06 1 -4.4e-16 4.4
## Q23 1 1.1e-16 4.2
## Q19 1 -8.9e-16 3.5
##
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10
## SS loadings 7.29 1.74 1.32 1.23 0.99 0.90 0.81 0.78 0.75 0.72
## Proportion Var 0.32 0.08 0.06 0.05 0.04 0.04 0.04 0.03 0.03 0.03
## Cumulative Var 0.32 0.39 0.45 0.50 0.55 0.59 0.62 0.65 0.69 0.72
## Proportion Explained 0.32 0.08 0.06 0.05 0.04 0.04 0.04 0.03 0.03 0.03
## Cumulative Proportion 0.32 0.39 0.45 0.50 0.55 0.59 0.62 0.65 0.69 0.72
## PC11 PC12 PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20
## SS loadings 0.68 0.67 0.61 0.58 0.55 0.52 0.51 0.46 0.42 0.41
## Proportion Var 0.03 0.03 0.03 0.03 0.02 0.02 0.02 0.02 0.02 0.02
## Cumulative Var 0.75 0.78 0.80 0.83 0.85 0.88 0.90 0.92 0.94 0.95
## Proportion Explained 0.03 0.03 0.03 0.03 0.02 0.02 0.02 0.02 0.02 0.02
## Cumulative Proportion 0.75 0.78 0.80 0.83 0.85 0.88 0.90 0.92 0.94 0.95
## PC21 PC22 PC23
## SS loadings 0.38 0.36 0.33
## Proportion Var 0.02 0.02 0.01
## Cumulative Var 0.97 0.99 1.00
## Proportion Explained 0.02 0.02 0.01
## Cumulative Proportion 0.97 0.99 1.00
##
## Mean item complexity = 5
## Test of the hypothesis that 23 components are sufficient.
##
## The root mean square of the residuals (RMSR) is 0
## with the empirical chi square 0 with prob < NA
##
## Fit based upon off diagonal values = 1
fa.diagram(pc1) #create a diagram showing the components and how the manifest variables load
fa.sort(pc1$loading) #Loadings of variables on to components
##
## Loadings:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10
## Q18 0.701 0.298 0.125 0.149 -0.105 -0.121
## Q07 0.685 0.252 0.103 0.166 0.134
## Q16 0.679 -0.138 -0.323 0.120 -0.144 -0.185 0.151
## Q13 0.673 0.278 0.132 -0.212 -0.220
## Q12 0.669 0.248 -0.139 -0.114
## Q21 0.658 -0.187 0.282 0.244 -0.146 0.183 0.103 0.119
## Q14 0.656 0.198 0.135 -0.144 0.164
## Q11 0.652 0.245 -0.209 -0.400 0.134 0.181 0.100 -0.144
## Q17 0.643 0.330 -0.210 -0.342 0.103
## Q04 0.634 0.144 -0.149 0.153 -0.202 -0.120 0.113 -0.106
## Q03 -0.629 0.290 0.213 0.196
## Q15 0.593 0.117 -0.113 0.292 0.316 -0.124 -0.270 0.411
## Q01 0.586 0.175 -0.215 0.119 -0.403 -0.108 -0.216
## Q05 0.556 0.101 0.137 -0.423 -0.171 0.106 0.237
## Q08 0.549 0.401 -0.323 -0.417 0.146
## Q10 0.437 0.363 -0.103 -0.342 0.217 0.436 0.369 -0.222
## Q20 0.436 -0.205 -0.404 0.297 0.326 0.337 0.328
## Q09 -0.284 0.627 0.103 0.174 -0.266 0.159 0.320
## Q02 -0.303 0.548 0.146 -0.385 0.194 -0.388 -0.122
## Q22 -0.302 0.465 -0.116 0.378 0.124 0.305 0.118 -0.414 -0.386
## Q06 0.562 0.571 0.171
## Q23 -0.144 0.366 0.507 0.616 -0.276 -0.216 0.179
## Q19 -0.427 0.390 -0.152 0.682 0.159
## PC11 PC12 PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20
## Q18 -0.111 0.445 -0.147
## Q07 -0.270 0.199 -0.223 -0.226 -0.149 0.205 0.156
## Q16 0.155 -0.186 0.118 -0.217 0.219
## Q13 0.239 0.120 0.138 -0.111 -0.324 -0.296
## Q12 0.195 -0.452 0.168 0.356
## Q21 -0.150 -0.266 0.205 -0.109 -0.307
## Q14 -0.286 0.141 -0.371 0.248 0.339
## Q11 -0.180
## Q17 -0.183 0.416
## Q04 0.340 -0.316 -0.174 0.115 0.311 0.194 -0.206
## Q03 0.147 0.105 0.133 0.401 0.429
## Q15 0.148 0.163 0.164 -0.121 -0.103
## Q01 0.112 -0.122 0.298 -0.250 0.176 0.122 -0.173 0.164
## Q05 -0.296 0.158 0.120 0.477
## Q08 0.122 -0.147
## Q10 -0.107 -0.211 -0.173 -0.152
## Q20 0.210 0.168 0.216 0.183
## Q09 -0.217 -0.365 -0.167 0.123 0.108 -0.191
## Q02 0.301 0.274 -0.240
## Q22 -0.187 0.155
## Q06 -0.125 0.197 0.244 0.200 -0.145
## Q23 0.135 -0.119
## Q19 0.292 -0.163
## PC21 PC22 PC23
## Q18 -0.182 0.228
## Q07 0.143 0.244
## Q16 0.349 -0.121
## Q13 0.164
## Q12 -0.100
## Q21 -0.202 -0.133
## Q14
## Q11 0.414
## Q17 -0.149 -0.234
## Q04
## Q03
## Q15 -0.195 0.101
## Q01 -0.208
## Q05
## Q08 0.163 -0.357
## Q10
## Q20 0.104
## Q09
## Q02
## Q22
## Q06 -0.320 -0.107
## Q23
## Q19
##
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10
## SS loadings 7.290 1.739 1.317 1.227 0.988 0.895 0.806 0.783 0.751 0.717
## Proportion Var 0.317 0.076 0.057 0.053 0.043 0.039 0.035 0.034 0.033 0.031
## Cumulative Var 0.317 0.393 0.450 0.503 0.546 0.585 0.620 0.654 0.687 0.718
## PC11 PC12 PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20
## SS loadings 0.684 0.670 0.612 0.578 0.549 0.523 0.508 0.456 0.424 0.408
## Proportion Var 0.030 0.029 0.027 0.025 0.024 0.023 0.022 0.020 0.018 0.018
## Cumulative Var 0.748 0.777 0.803 0.828 0.852 0.875 0.897 0.917 0.935 0.953
## PC21 PC22 PC23
## SS loadings 0.379 0.364 0.333
## Proportion Var 0.016 0.016 0.014
## Cumulative Var 0.970 0.986 1.000
pc1$communality #Communalities of variables across components (will be one for PCA since all the variance is used)
## Q01 Q02 Q03 Q04 Q05 Q06 Q07 Q08 Q09 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## Q19 Q20 Q21 Q22 Q23
## 1 1 1 1 1
plot(pc1$values, type = "b") #scree plot
pc1$Vaccounted
## PC1 PC2 PC3 PC4
## SS loadings 7.2900471 1.73882875 1.31675153 1.22719815
## Proportion Var 0.3169586 0.07560125 0.05725007 0.05335644
## Cumulative Var 0.3169586 0.39255982 0.44980988 0.50316633
## Proportion Explained 0.3169586 0.07560125 0.05725007 0.05335644
## Cumulative Proportion 0.3169586 0.39255982 0.44980988 0.50316633
## PC5 PC6 PC7 PC8
## SS loadings 0.98787789 0.89533041 0.80556039 0.78281994
## Proportion Var 0.04295121 0.03892741 0.03502436 0.03403565
## Cumulative Var 0.54611754 0.58504495 0.62006931 0.65410496
## Proportion Explained 0.04295121 0.03892741 0.03502436 0.03403565
## Cumulative Proportion 0.54611754 0.58504495 0.62006931 0.65410496
## PC9 PC10 PC11 PC12
## SS loadings 0.75097119 0.71695772 0.68358773 0.66950156
## Proportion Var 0.03265092 0.03117207 0.02972121 0.02910876
## Cumulative Var 0.68675588 0.71792796 0.74764916 0.77675793
## Proportion Explained 0.03265092 0.03117207 0.02972121 0.02910876
## Cumulative Proportion 0.68675588 0.71792796 0.74764916 0.77675793
## PC13 PC14 PC15 PC16
## SS loadings 0.61199758 0.57773774 0.54918754 0.52315038
## Proportion Var 0.02660859 0.02511903 0.02387772 0.02274567
## Cumulative Var 0.80336652 0.82848555 0.85236327 0.87510894
## Proportion Explained 0.02660859 0.02511903 0.02387772 0.02274567
## Cumulative Proportion 0.80336652 0.82848555 0.85236327 0.87510894
## PC17 PC18 PC19 PC20
## SS loadings 0.50839618 0.45593985 0.42380357 0.40779093
## Proportion Var 0.02210418 0.01982347 0.01842624 0.01773004
## Cumulative Var 0.89721312 0.91703659 0.93546283 0.95319287
## Proportion Explained 0.02210418 0.01982347 0.01842624 0.01773004
## Cumulative Proportion 0.89721312 0.91703659 0.93546283 0.95319287
## PC21 PC22 PC23
## SS loadings 0.37947986 0.36402226 0.33306180
## Proportion Var 0.01649912 0.01582705 0.01448095
## Cumulative Var 0.96969200 0.98551905 1.00000000
## Proportion Explained 0.01649912 0.01582705 0.01448095
## Cumulative Proportion 0.96969200 0.98551905 1.00000000
pc1$values #output eigenvalues
## [1] 7.2900471 1.7388287 1.3167515 1.2271982 0.9878779 0.8953304 0.8055604
## [8] 0.7828199 0.7509712 0.7169577 0.6835877 0.6695016 0.6119976 0.5777377
## [15] 0.5491875 0.5231504 0.5083962 0.4559399 0.4238036 0.4077909 0.3794799
## [22] 0.3640223 0.3330618
#Another way to look at eigen values plus variance explained (need to use princomp function fof PCA to get right class for use with factoextra dunctions)
pcf=princomp(raqData)
factoextra::get_eigenvalue(pcf)
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 7.0430039 31.059169 31.05917
## Dim.2 1.9919543 8.784383 39.84355
## Dim.3 1.3755696 6.066168 45.90972
## Dim.4 1.1415644 5.034221 50.94394
## Dim.5 1.0453716 4.610018 55.55396
## Dim.6 0.8929067 3.937658 59.49162
## Dim.7 0.8530615 3.761943 63.25356
## Dim.8 0.8136079 3.587955 66.84152
## Dim.9 0.7489525 3.302830 70.14435
## Dim.10 0.7054281 3.110890 73.25524
## Dim.11 0.6894466 3.040413 76.29565
## Dim.12 0.6195139 2.732014 79.02766
## Dim.13 0.5624056 2.480171 81.50783
## Dim.14 0.5500250 2.425573 83.93341
## Dim.15 0.5309084 2.341270 86.27468
## Dim.16 0.4993591 2.202140 88.47682
## Dim.17 0.4795848 2.114936 90.59175
## Dim.18 0.4450189 1.962503 92.55425
## Dim.19 0.4176764 1.841924 94.39618
## Dim.20 0.3794383 1.673297 96.06948
## Dim.21 0.3216300 1.418366 97.48784
## Dim.22 0.3096743 1.365643 98.85349
## Dim.23 0.2599847 1.146515 100.00000
factoextra::fviz_eig(pcf, addlabels = TRUE, ylim = c(0, 50))#Visualise the Eigenvalues
factoextra::fviz_pca_var(pcf, col.var = "black")
factoextra::fviz_pca_var(pcf, col.var = "cos2",
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
#VIsualise contribution of variables
var <- factoextra::get_pca_var(pcf)
corrplot::corrplot(var$contrib, is.corr=FALSE)
# Contributions of variables to PC1
factoextra::fviz_contrib(pcf, choice = "var", axes = 1, top = 10)
# Contributions of variables to PC2
factoextra::fviz_contrib(pcf, choice = "var", axes = 2, top = 10)
#PCA with rotation
pc2 <- principal(raqData, nfactors = 4, rotate = "varimax")#Extracting 4 factors
psych::print.psych(pc2, cut = 0.3, sort = TRUE)
## Principal Components Analysis
## Call: principal(r = raqData, nfactors = 4, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
## item RC3 RC1 RC4 RC2 h2 u2 com
## Q06 6 0.80 0.65 0.35 1.0
## Q18 18 0.68 0.33 0.60 0.40 1.5
## Q13 13 0.65 0.54 0.46 1.6
## Q07 7 0.64 0.33 0.55 0.45 1.7
## Q14 14 0.58 0.36 0.49 0.51 1.8
## Q10 10 0.55 0.33 0.67 1.2
## Q15 15 0.46 0.38 0.62 2.6
## Q20 20 0.68 0.48 0.52 1.1
## Q21 21 0.66 0.55 0.45 1.5
## Q03 3 -0.57 0.37 0.53 0.47 2.3
## Q12 12 0.47 0.52 0.51 0.49 2.1
## Q04 4 0.32 0.52 0.31 0.47 0.53 2.4
## Q16 16 0.33 0.51 0.31 0.49 0.51 2.6
## Q01 1 0.50 0.36 0.43 0.57 2.4
## Q05 5 0.32 0.43 0.34 0.66 2.5
## Q08 8 0.83 0.74 0.26 1.1
## Q17 17 0.75 0.68 0.32 1.5
## Q11 11 0.75 0.69 0.31 1.5
## Q09 9 0.65 0.48 0.52 1.3
## Q22 22 0.65 0.46 0.54 1.2
## Q23 23 0.59 0.41 0.59 1.4
## Q02 2 -0.34 0.54 0.41 0.59 1.7
## Q19 19 -0.37 0.43 0.34 0.66 2.2
##
## RC3 RC1 RC4 RC2
## SS loadings 3.73 3.34 2.55 1.95
## Proportion Var 0.16 0.15 0.11 0.08
## Cumulative Var 0.16 0.31 0.42 0.50
## Proportion Explained 0.32 0.29 0.22 0.17
## Cumulative Proportion 0.32 0.61 0.83 1.00
##
## Mean item complexity = 1.8
## Test of the hypothesis that 4 components are sufficient.
##
## The root mean square of the residuals (RMSR) is 0.06
## with the empirical chi square 4006.15 with prob < 0
##
## Fit based upon off diagonal values = 0.96
pc2$communality
## Q01 Q02 Q03 Q04 Q05 Q06 Q07
## 0.4346477 0.4137525 0.5297160 0.4685890 0.3430498 0.6539317 0.5452943
## Q08 Q09 Q10 Q11 Q12 Q13 Q14
## 0.7394635 0.4844805 0.3347726 0.6896049 0.5133281 0.5358284 0.4882649
## Q15 Q16 Q17 Q18 Q19 Q20 Q21
## 0.3779918 0.4870822 0.6828085 0.5973378 0.3432423 0.4839965 0.5499069
## Q22 Q23
## 0.4635443 0.4121913
#Factor Analysis
#Principal Axis Factoring
pc3 <- fa(raqMatrix, nfactors=4, obs=NA, n.iter=1, rotate="varimax", fm="pa")
psych::print.psych(pc3,cut=0.3, sort=TRUE)
## Factor Analysis using method = pa
## Call: fa(r = raqMatrix, nfactors = 4, n.iter = 1, rotate = "varimax",
## fm = "pa", obs = NA)
## Standardized loadings (pattern matrix) based upon correlation matrix
## item PA1 PA3 PA4 PA2 h2 u2 com
## Q21 21 0.59 0.47 0.53 1.7
## Q16 16 0.54 0.46 0.54 2.2
## Q04 4 0.53 0.42 0.58 2.0
## Q12 12 0.51 0.40 0.45 0.55 2.2
## Q03 3 -0.50 0.40 0.47 0.53 2.4
## Q01 1 0.50 0.37 0.63 1.9
## Q20 20 0.46 0.27 0.73 1.5
## Q05 5 0.44 0.30 0.70 2.1
## Q06 6 0.75 0.59 0.41 1.1
## Q18 18 0.37 0.61 0.54 0.46 1.9
## Q13 13 0.56 0.47 0.53 2.0
## Q07 7 0.36 0.56 0.49 0.51 2.1
## Q14 14 0.39 0.49 0.42 0.58 2.3
## Q10 10 0.38 0.20 0.80 1.8
## Q15 15 0.38 0.32 0.68 3.3
## Q08 8 0.76 0.65 0.35 1.2
## Q11 11 0.69 0.63 0.37 1.7
## Q17 17 0.64 0.58 0.42 1.8
## Q09 9 0.56 0.34 0.66 1.2
## Q22 22 0.47 0.25 0.75 1.3
## Q02 2 0.46 0.26 0.74 1.4
## Q19 19 0.38 0.24 0.76 2.3
## Q23 23 0.33 0.12 0.88 1.2
##
## PA1 PA3 PA4 PA2
## SS loadings 3.03 2.85 1.99 1.44
## Proportion Var 0.13 0.12 0.09 0.06
## Cumulative Var 0.13 0.26 0.34 0.40
## Proportion Explained 0.33 0.31 0.21 0.15
## Cumulative Proportion 0.33 0.63 0.85 1.00
##
## Mean item complexity = 1.8
## Test of the hypothesis that 4 factors are sufficient.
##
## The degrees of freedom for the null model are 253 and the objective function was 7.55
## The degrees of freedom for the model are 167 and the objective function was 0.46
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.03
##
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## PA1 PA3 PA4 PA2
## Correlation of (regression) scores with factors 0.83 0.86 0.86 0.77
## Multiple R square of scores with factors 0.69 0.73 0.74 0.59
## Minimum correlation of possible factor scores 0.37 0.46 0.49 0.19
fa.sort(pc3$loading)
##
## Loadings:
## PA1 PA3 PA4 PA2
## Q21 0.594 0.264 0.149 -0.150
## Q16 0.543 0.279 0.245 -0.156
## Q04 0.527 0.281 0.248
## Q12 0.510 0.398 0.108 -0.153
## Q03 -0.505 -0.181 -0.159 0.399
## Q01 0.504 0.218 0.266
## Q20 0.465 -0.204
## Q05 0.436 0.268 0.187
## Q06 0.752 0.124
## Q18 0.366 0.612 0.136 -0.130
## Q13 0.287 0.564 0.228 -0.144
## Q07 0.364 0.559 0.161 -0.132
## Q14 0.388 0.485 0.148 -0.130
## Q10 0.142 0.380 0.135 -0.121
## Q15 0.276 0.377 0.251 -0.200
## Q08 0.218 0.149 0.759
## Q11 0.237 0.267 0.688 -0.170
## Q17 0.295 0.274 0.641
## Q09 -0.133 0.559
## Q22 -0.158 0.465
## Q02 -0.209 0.464
## Q19 -0.282 -0.146 0.375
## Q23 0.329
##
## PA1 PA3 PA4 PA2
## SS loadings 3.034 2.854 1.986 1.435
## Proportion Var 0.132 0.124 0.086 0.062
## Cumulative Var 0.132 0.256 0.342 0.405
fa.diagram(pc3)#create a diagram showing the factors and how the manifest variables load
plot(pc3$values, type = "b") #scree plot
pc3$Vaccounted#Variance accounted for
## PA1 PA3 PA4 PA2
## SS loadings 3.0336437 2.8544922 1.98593932 1.43509365
## Proportion Var 0.1318976 0.1241084 0.08634519 0.06239538
## Cumulative Var 0.1318976 0.2560059 0.34235109 0.40474647
## Proportion Explained 0.3258770 0.3066323 0.21333154 0.15415916
## Cumulative Proportion 0.3258770 0.6325093 0.84584084 1.00000000
pc3$values #output eigenvalues
## [1] 6.744239770 1.127426329 0.813546572 0.623956135 0.356603439
## [6] 0.179270219 0.145802064 0.122062601 0.084452751 0.058982601
## [11] 0.035022732 0.027488386 -0.002470793 -0.018079811 -0.032357268
## [16] -0.056582032 -0.071660829 -0.078114007 -0.113999668 -0.126406167
## [21] -0.135081760 -0.168676086 -0.207179684
computerFear<-raqData[,c(6, 7, 10, 13, 14, 15, 18)]
statisticsFear <- raqData[, c(1, 3, 4, 5, 12, 16, 20, 21)]
mathFear <- raqData[, c(8, 11, 17)]
peerEvaluation <- raqData[, c(2, 9, 19, 22, 23)]
psych::alpha(computerFear)
##
## Reliability analysis
## Call: psych::alpha(x = computerFear)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.82 0.81 0.4 4.6 0.0052 3.4 0.71 0.39
##
## lower alpha upper 95% confidence boundaries
## 0.81 0.82 0.83
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Q06 0.79 0.79 0.77 0.38 3.7 0.0063 0.0081 0.38
## Q07 0.79 0.79 0.77 0.38 3.7 0.0063 0.0079 0.36
## Q10 0.82 0.82 0.80 0.44 4.7 0.0053 0.0043 0.44
## Q13 0.79 0.79 0.77 0.39 3.8 0.0062 0.0081 0.38
## Q14 0.80 0.80 0.77 0.39 3.9 0.0060 0.0085 0.36
## Q15 0.81 0.81 0.79 0.41 4.2 0.0056 0.0095 0.44
## Q18 0.79 0.78 0.76 0.38 3.6 0.0064 0.0058 0.38
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Q06 2571 0.75 0.74 0.68 0.62 3.8 1.12
## Q07 2571 0.75 0.73 0.68 0.62 3.1 1.10
## Q10 2571 0.54 0.57 0.44 0.40 3.7 0.88
## Q13 2571 0.72 0.73 0.67 0.61 3.6 0.95
## Q14 2571 0.70 0.70 0.64 0.58 3.1 1.00
## Q15 2571 0.64 0.64 0.54 0.49 3.2 1.01
## Q18 2571 0.76 0.76 0.72 0.65 3.4 1.05
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Q06 0.06 0.10 0.13 0.44 0.27 0
## Q07 0.09 0.24 0.26 0.34 0.07 0
## Q10 0.02 0.10 0.18 0.57 0.14 0
## Q13 0.03 0.12 0.25 0.48 0.12 0
## Q14 0.07 0.18 0.38 0.31 0.06 0
## Q15 0.06 0.18 0.30 0.39 0.07 0
## Q18 0.06 0.12 0.31 0.37 0.14 0
psych::alpha(statisticsFear, keys = c(1, -1, 1, 1, 1, 1, 1, 1))
##
## Reliability analysis
## Call: psych::alpha(x = statisticsFear, keys = c(1, -1, 1, 1, 1, 1,
## 1, 1))
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.82 0.81 0.37 4.7 0.0053 3 0.64 0.4
##
## lower alpha upper 95% confidence boundaries
## 0.81 0.82 0.83
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Q01 0.80 0.80 0.79 0.37 4.1 0.0060 0.0052 0.40
## Q03- 0.80 0.80 0.79 0.37 4.1 0.0061 0.0070 0.40
## Q04 0.80 0.80 0.78 0.36 4.0 0.0062 0.0061 0.35
## Q05 0.81 0.81 0.80 0.38 4.2 0.0058 0.0058 0.41
## Q12 0.80 0.80 0.79 0.36 4.0 0.0061 0.0067 0.39
## Q16 0.79 0.80 0.78 0.36 3.9 0.0062 0.0057 0.35
## Q20 0.82 0.82 0.80 0.40 4.6 0.0055 0.0022 0.41
## Q21 0.79 0.80 0.78 0.36 3.9 0.0063 0.0063 0.38
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Q01 2571 0.65 0.67 0.60 0.54 3.6 0.83
## Q03- 2571 0.69 0.67 0.60 0.55 2.6 1.08
## Q04 2571 0.69 0.70 0.64 0.58 3.2 0.95
## Q05 2571 0.63 0.63 0.55 0.49 3.3 0.96
## Q12 2571 0.69 0.69 0.63 0.57 2.8 0.92
## Q16 2571 0.71 0.71 0.67 0.60 3.1 0.92
## Q20 2571 0.58 0.56 0.47 0.42 2.4 1.04
## Q21 2571 0.72 0.71 0.67 0.61 2.8 0.98
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Q01 0.02 0.07 0.29 0.52 0.11 0
## Q03 0.03 0.17 0.34 0.26 0.19 0
## Q04 0.05 0.17 0.36 0.37 0.05 0
## Q05 0.04 0.18 0.29 0.43 0.06 0
## Q12 0.09 0.23 0.46 0.20 0.02 0
## Q16 0.06 0.16 0.42 0.33 0.04 0
## Q20 0.22 0.37 0.25 0.15 0.02 0
## Q21 0.09 0.29 0.34 0.26 0.02 0
psych::alpha(mathFear)
##
## Reliability analysis
## Call: psych::alpha(x = mathFear)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.82 0.82 0.75 0.6 4.5 0.0062 3.7 0.75 0.59
##
## lower alpha upper 95% confidence boundaries
## 0.81 0.82 0.83
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Q08 0.74 0.74 0.59 0.59 2.8 0.010 NA 0.59
## Q11 0.74 0.74 0.59 0.59 2.9 0.010 NA 0.59
## Q17 0.77 0.77 0.63 0.63 3.4 0.009 NA 0.63
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Q08 2571 0.86 0.86 0.76 0.68 3.8 0.87
## Q11 2571 0.86 0.86 0.75 0.68 3.7 0.88
## Q17 2571 0.85 0.85 0.72 0.65 3.5 0.88
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Q08 0.03 0.06 0.19 0.58 0.15 0
## Q11 0.02 0.06 0.22 0.53 0.16 0
## Q17 0.03 0.10 0.27 0.52 0.08 0
psych::alpha(peerEvaluation)
##
## Reliability analysis
## Call: psych::alpha(x = peerEvaluation)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.57 0.57 0.53 0.21 1.3 0.013 3.4 0.65 0.23
##
## lower alpha upper 95% confidence boundaries
## 0.54 0.57 0.6
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Q02 0.52 0.52 0.45 0.21 1.07 0.015 0.0028 0.23
## Q09 0.48 0.48 0.41 0.19 0.92 0.017 0.0036 0.22
## Q19 0.52 0.53 0.46 0.22 1.11 0.015 0.0055 0.23
## Q22 0.49 0.49 0.43 0.19 0.96 0.016 0.0065 0.19
## Q23 0.56 0.57 0.50 0.25 1.32 0.014 0.0014 0.24
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Q02 2571 0.56 0.61 0.45 0.34 4.4 0.85
## Q09 2571 0.70 0.66 0.53 0.39 3.2 1.26
## Q19 2571 0.61 0.60 0.42 0.32 3.7 1.10
## Q22 2571 0.64 0.64 0.50 0.38 3.1 1.04
## Q23 2571 0.53 0.53 0.31 0.24 2.6 1.04
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Q02 0.01 0.04 0.08 0.31 0.56 0
## Q09 0.08 0.28 0.23 0.20 0.20 0
## Q19 0.02 0.15 0.22 0.33 0.29 0
## Q22 0.05 0.26 0.34 0.26 0.10 0
## Q23 0.12 0.42 0.27 0.12 0.06 0
psych::alpha(statisticsFear) #for illustrative pruposes
## Warning in psych::alpha(statisticsFear): Some items were negatively correlated with the total scale and probably
## should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Some items ( Q03 ) were negatively correlated with the total scale and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
##
## Reliability analysis
## Call: psych::alpha(x = statisticsFear)
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.61 0.64 0.71 0.18 1.8 0.01 3.1 0.5 0.34
##
## lower alpha upper 95% confidence boundaries
## 0.59 0.61 0.63
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Q01 0.52 0.56 0.64 0.15 1.3 0.0128 0.123 0.33
## Q03 0.80 0.80 0.79 0.37 4.1 0.0061 0.007 0.40
## Q04 0.50 0.55 0.64 0.15 1.2 0.0133 0.119 0.33
## Q05 0.52 0.57 0.66 0.16 1.3 0.0127 0.129 0.33
## Q12 0.52 0.56 0.65 0.15 1.3 0.0131 0.120 0.33
## Q16 0.51 0.55 0.63 0.15 1.2 0.0133 0.116 0.33
## Q20 0.56 0.60 0.68 0.18 1.5 0.0118 0.133 0.39
## Q21 0.50 0.55 0.63 0.15 1.2 0.0136 0.117 0.30
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Q01 2571 0.65 0.68 0.62 0.51 3.6 0.83
## Q03 2571 -0.35 -0.37 -0.64 -0.55 3.4 1.08
## Q04 2571 0.69 0.69 0.65 0.53 3.2 0.95
## Q05 2571 0.65 0.65 0.57 0.47 3.3 0.96
## Q12 2571 0.66 0.67 0.62 0.50 2.8 0.92
## Q16 2571 0.69 0.70 0.66 0.53 3.1 0.92
## Q20 2571 0.57 0.55 0.45 0.35 2.4 1.04
## Q21 2571 0.70 0.70 0.66 0.54 2.8 0.98
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Q01 0.02 0.07 0.29 0.52 0.11 0
## Q03 0.03 0.17 0.34 0.26 0.19 0
## Q04 0.05 0.17 0.36 0.37 0.05 0
## Q05 0.04 0.18 0.29 0.43 0.06 0
## Q12 0.09 0.23 0.46 0.20 0.02 0
## Q16 0.06 0.16 0.42 0.33 0.04 0
## Q20 0.22 0.37 0.25 0.15 0.02 0
## Q21 0.09 0.29 0.34 0.26 0.02 0